﻿namespace Sidvall.AuthorizationManager.Net.Services.V1.Model
{
    public class ResourceFactory : global::Sidvall.Data.IResourceFactory
    {
        #region CreateItem

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
        public object CreateItem(string resource, Sidvall.Data.DataRowState? dataRowState)
        {
            switch (resource)
            {
                case global::Sidvall.AuthorizationManager.Data.Model.DomainObjects.AuthorizationScope:
                    return new global::Sidvall.AuthorizationManager.Net.Services.V1.AuthorizationScope(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.AuthorizationManager.Data.Model.DomainObjects.AuthorizationScopeExport:
                    return new global::Sidvall.AuthorizationManager.Net.Services.V1.AuthorizationScopeExport(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.AuthorizationManager.Data.Model.DomainObjects.AuthorizationScopeResourceAction:
                    return new global::Sidvall.AuthorizationManager.Net.Services.V1.AuthorizationScopeResourceAction(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.AuthorizationManager.Data.Model.DomainObjects.AuthorizationScopeResourceActionClaim:
                    return new global::Sidvall.AuthorizationManager.Net.Services.V1.AuthorizationScopeResourceActionClaim(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.AuthorizationManager.Data.Model.DomainObjects.AuthorizationScopeResourceItem:
                    return new global::Sidvall.AuthorizationManager.Net.Services.V1.AuthorizationScopeResourceItem(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.AuthorizationManager.Data.Model.DomainObjects.AuthorizationScopeResourceItemClaim:
                    return new global::Sidvall.AuthorizationManager.Net.Services.V1.AuthorizationScopeResourceItemClaim(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.AuthorizationManager.Data.Model.DomainObjects.AuthorizationScopeUser:
                    return new global::Sidvall.AuthorizationManager.Net.Services.V1.AuthorizationScopeUser(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                default:
                    return null;
            }
        }

        #endregion
        #region CreateItems

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
        public object CreateItems(string resource)
        {
            switch (resource)
            {
                case global::Sidvall.AuthorizationManager.Data.Model.DomainObjects.AuthorizationScope:
                    return new global::Sidvall.AuthorizationManager.Net.Services.V1.AuthorizationScopeCollectionItem();
                case global::Sidvall.AuthorizationManager.Data.Model.DomainObjects.AuthorizationScopeExport:
                    return new global::Sidvall.AuthorizationManager.Net.Services.V1.AuthorizationScopeExportCollectionItem();
                case global::Sidvall.AuthorizationManager.Data.Model.DomainObjects.AuthorizationScopeResourceAction:
                    return new global::Sidvall.AuthorizationManager.Net.Services.V1.AuthorizationScopeResourceActionCollectionItem();
                case global::Sidvall.AuthorizationManager.Data.Model.DomainObjects.AuthorizationScopeResourceActionClaim:
                    return new global::Sidvall.AuthorizationManager.Net.Services.V1.AuthorizationScopeResourceActionClaimCollectionItem();
                case global::Sidvall.AuthorizationManager.Data.Model.DomainObjects.AuthorizationScopeResourceItem:
                    return new global::Sidvall.AuthorizationManager.Net.Services.V1.AuthorizationScopeResourceItemCollectionItem();
                case global::Sidvall.AuthorizationManager.Data.Model.DomainObjects.AuthorizationScopeResourceItemClaim:
                    return new global::Sidvall.AuthorizationManager.Net.Services.V1.AuthorizationScopeResourceItemClaimCollectionItem();
                case global::Sidvall.AuthorizationManager.Data.Model.DomainObjects.AuthorizationScopeUser:
                    return new global::Sidvall.AuthorizationManager.Net.Services.V1.AuthorizationScopeUserCollectionItem();
                default:
                    return null;
            }
        }
        
        #endregion
        
        #region Current

        private static readonly System.Lazy<ResourceFactory> _Current = new System.Lazy<ResourceFactory>(() => new ResourceFactory());
        public static ResourceFactory Current
        {
            get
            {
                return _Current.Value;
            }
        }

        #endregion
    }
}